import { Column, Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import {BaseEntity} from "../../../../common/entities/base";
import {ProfessionalEntity} from "./professional.entity";
import {CourseEntity} from "../../course/entities/course.entity";

@Entity('edu_professional_course', {
  comment: '专业与课程关联表',
})
export class ProfessionalCourseEntity extends  BaseEntity{
  @PrimaryGeneratedColumn({ type: 'int', name: 'id', comment: '主键ID' })
  public id: number;

  @ApiProperty({ description: '专业ID' })
  @Column({ type: 'int', name: 'pro_id', default:null, comment: '专业ID' })
  public proId: number;

  @ApiProperty({ description: '课程ID' })
  @Column({ type: 'int', name: 'course_id', default:null, comment: '课程ID' })
  public courseId: number;

  @ManyToOne(() => CourseEntity, course => course.courseId)
  @JoinColumn({ name: 'course_id' })
  public course: CourseEntity;

  @ManyToOne(() => ProfessionalEntity, professional => professional.proId)
  @JoinColumn({ name: 'pro_id' })
  public professional: ProfessionalEntity;
}
